package com.aaa.sys.controller;

import com.aaa.sys.entity.TabRole;
import com.aaa.sys.service.TabRoleService;
import com.aaa.sys.service.impl.TabRoleServiceImpl;
import com.util.LayData;
import com.util.PrintJsonData;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * (TabRole)表控制层
 *
 * @author makejava
 * @since 2023-04-25 09:25:25
 */


@WebServlet(name = "TabRoleServlet", value = "/TabRoleServlet")
public class TabRoleServlet extends HttpServlet {

    private TabRoleService tabRoleService = new TabRoleServiceImpl();

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        // 
        String method = req.getParameter("method");
        if (method==null){
          

        }else if(method.equals("query")){
            query(req,resp);
            return;
        }else if(method.equals("add")){
            add(req,resp);
            return;
        }else if(method.equals("upd")){
            upd(req,resp);
            return;
        }else if(method.equals("del")){
            del(req,resp);
            return;
        }

    }

  

    private void del(HttpServletRequest req, HttpServletResponse resp) {
    }

    private void upd(HttpServletRequest req, HttpServletResponse resp) {
    }

    private void add(HttpServletRequest req, HttpServletResponse resp) {
    }

    private void query(HttpServletRequest req, HttpServletResponse resp) {
        // 查询出所有的角色的信息
        List<TabRole> tabRoles = tabRoleService.queryAll(null);
        // LayData
        long count = tabRoleService.count(null);
        LayData success = LayData.success((int) count, tabRoles);
        PrintJsonData.printData(resp,success);


    }
}




